A good answer might be:

As it is written, calling fact( -1 ) would grow the activation chain without limit. Eventually the computer system would run out of resources, and the program would stop running.

int fact( int N )
{
  if ( N == 0 )
    return 1;
  else
    return N * fact( N-1 ) ;
}

Defensive Programming

Defensive programming is when the programmer anticipates problems and writes code to deal with them. To avoid the disaster a negative parameter would cause, sometimes fact() is written like this:

int fact( int N )
{
  if ( N <= 0 )
    return 1;
  else
    return N * fact( N-1 ) ;
}

But, according to the math-like definition, this is not correct. The value of factorial( -1 ) is undefined, not equal to one. Potentially, returning an incorrect value and continuing on as if nothing is wrong might cause a greater disaster than stopping the computer system.

Sometimes the method is written to throw an exception when an illegal argument is detected. But this adds complication since any caller is now required to deal with the exception (or pass it on to its caller.)

Possibly the best solution is to write factorial() so that it follows the math-like definition exactly, but require that any caller of the function check that the arguments are within range.

QUESTION 5:

Here is another idea: why not have factorial() take the absolute value of its argument to be sure that it is positive?